package d6_pool;

import java.util.concurrent.*;

public class t4 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ExecutorService pool = new ThreadPoolExecutor(3,5,8, TimeUnit.SECONDS,new LinkedBlockingQueue<Runnable>(2),
                Executors.defaultThreadFactory(),new ThreadPoolExecutor.CallerRunsPolicy());
        //线程池工具类
        ExecutorService pool2 = Executors.newFixedThreadPool(17);

        Future<String> f1 = pool.submit(new MyCallable(100));
        Future<String> f2 = pool.submit(new MyCallable(200));
        Future<String> f3 = pool.submit(new MyCallable(300));
        Future<String> f4 = pool.submit(new MyCallable(400));
        Future<String> f5 = pool.submit(new MyCallable(500));

        System.out.println(f1.get());
        System.out.println(f2.get());
        System.out.println(f3.get());
        System.out.println(f4.get());
        System.out.println(f5.get());

    }
}
